package com.example.index.web.feign;

import com.example.index.web.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

// 不带降级配置
// @FeignClient("user")
// 带降级配置,  设置降级类
@FeignClient(name="user", fallback = UserActionHystrix.class)
public interface IUserAction {

    @RequestMapping("user")
    public String user();

    @RequestMapping("hello")
    public String hello(@RequestParam("name") String name);

    @RequestMapping("add")
    public int add(@RequestParam("a") int a, @RequestParam("b") int b);

    /**
     * @RequestParam 用于给简单参数添加参数名
     *               请求参数在地址中, 头行
     * @RequestBody 会将对象参数写入请求body中, json 格式
     *              只能有一个body参数
     */
    @RequestMapping("reg")
    public User reg(@RequestBody User user);

    @RequestMapping("path/{ptest}")
    public String ptest(@PathVariable("ptest") String ptest);
}
